package com.spring.soundsystem.CoreAOP;

import java.lang.reflect.Proxy;

public class ProxyExe {
    public static void main(String[] args){
        System.out.println("------------------Proved------------------");
        UserBeanImpl targetObject = new UserBeanImpl("Li Liang");
        UserBeanProxy proxy = new UserBeanProxy(targetObject);
        UserBean object = (UserBean)Proxy.newProxyInstance(targetObject.getClass().getClassLoader(), targetObject.getClass().getInterfaces(), proxy);
        object.addUser();
        System.out.println("-----------------Not Proved----------------");
        targetObject = new UserBeanImpl();
        proxy = new UserBeanProxy(targetObject);
        object = (UserBean) Proxy.newProxyInstance(targetObject.getClass().getClassLoader(), targetObject.getClass().getInterfaces(), proxy);
        object.addUser();

    }
}
